<template>
	<view class="page">
		<div class="headers">
			<u-swiper :list="loginLunBo" keyName="image" :current="current" :indicator="true" indicatorMode="dot"
				height="100%" radius="10rpx" style="width: 100%;"></u-swiper>
		</div>
		<view class="items">
			<view class="itemsTip">
				{{$t('yzPassword')}}
			</view>
			<view class="sd">
				<u--input :placeholder="$t('yzPleaseenterpassword')" border="surround" v-model="FormData.password"
					:customStyle="{width:'650rpx',height:'49rpx'}" password></u--input>
				<image src="../../../static/53.png" mode=""
					style="width: 54rpx;height: 54rpx;position: absolute;right: 18rpx;"></image>

			</view>
		</view>

		<u-button type="primary" :text="$t('Verify')"
			:customStyle="{width:'672rpx',height:'80rpx',backgroundColor:'#445F79',color:'#fff',margin:'30px auto 0rpx',border:'none',fontSize:'16rpx',borderRadius: '40rpx'}"
			@click="homeLogin"></u-button>
		<u-button type="primary" :text="$t('Back')"
			:customStyle="{width:'672rpx',height:'80rpx',backgroundColor:'#445F79',color:'#fff',margin:'30px auto 0rpx',border:'none',fontSize:'16rpx',borderRadius: '40rpx'}"
			@click="back"></u-button>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				newUrl: 0, //0为新接口1为老接口
				loginLunBo: [], //轮播图的数据源
				FormData: {
					password: ''
				}
			}
		},
		onShow() {
			this.getLunBao()
			
		},
		methods: {

			// 获取首页轮播
			getLunBao() {
				uni.showLoading({
					title: this.$t('Laoding'),
				})
				this.$get('/biz/app/carouselImageList', {
					type: 1
				}, 0).then(res => {
					this.loginLunBo = res.data.data.map(items => {
						return {
							image: items.image,
						}
					})
				})
			},

			// 返回首页
			back() {
				uni.navigateBack()
			},
			// 登录
			homeLogin() {
				if (this.FormData.password == '') {
					return this.$ToastFail(this.$t('yzPasswordtips'))
				} else {
					let reg = /^[\w]{6,18}$/
					if (reg.test(this.FormData.password) == false) {
						return this.$ToastFail(this.$t('regtips'))
					}

				}				
				uni.showLoading({
					title: this.$t('Laoding'),
				})
				this.$post(`/biz/librarypwd/check`, this.FormData, this.newUrl).then(res => {
					console.log(res,'resresresresresresresresresresresresresres');
					if (res.message == "密码正确") {
						this.$ToastOk(this.$t('Verificationsuccessful'))
						setTimeout(() => {
							// uni.setStorageSync('libraryRelease', true)
							uni.setStorageSync('lgpad', this.FormData.password)
							uni.navigateTo({
								url:'/pages/home/Library'
							})
						}, 1000)

					} else {
						// uni.setStorageSync('libraryRelease', false)
						this.$ToastFail(`${res.message}`)
					}
				})

			}
		}
	}
</script>

<style>
	.page {
		overflow: hidden;
		width: 100%;
		height: 100vh;
		/* background-color: cornflowerblue; */
	}

	.headers {
		width: 700rpx;
		height: 350rpx;
		background-color: #fff;
		margin: 60rpx auto 0;
		padding: 15rpx;
		box-sizing: border-box;
	}

	.items {
		display: flex;
		align-items: flex-start;
		justify-content: center;
		flex-direction: column;
		width: 100%;
		height: 160rpx;
		/* background-color: cadetblue; */
		margin: 30rpx auto 0;
		padding: 0 42rpx;
		box-sizing: border-box;
	}

	.itemsTip {
		height: 54rpx;
		/* font-family: Roboto; */
		font-family: 'PingFang SC';
		font-size: 18px;
		font-weight: 500;
		line-height: 40rpx;
		letter-spacing: 0em;
		text-align: left;
		color: #333;
	}

	.sd {
		position: relative;
		display: flex;
		/* justify-content: flex-start; */
		align-items: center;
		width: 100%;
		height: 80rpx;
		/* background-color: red; */
	}

	.actib {
		/* font-family: Roboto; */
		font-family: 'PingFang SC';
		font-size: 30rpx;
		font-weight: 400;
		line-height: 70rpx;
		letter-spacing: 0em;
		text-align: center;
		width: 80rpx;
		height: 80rpx;
		background-color: #F5F5F5;
		margin-right: 20rpx;
	}

	.selectZhong {
		background-color: #445F79;
		color: #fff;
		border-radius: 10rpx;

	}
</style>